/*劳务服务*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:frametrim/activity/projectAttendanceManagementPage.dart';
import 'package:frametrim/activity/salaryQueryPage.dart';
import 'package:frametrim/activity/salarySurePage.dart';
import 'package:frametrim/app/app_navigator.dart';
import 'package:frametrim/utility/screen.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:frametrim/utility/sq_color.dart';
import 'package:frametrim/appviews/blockLogView.dart';
import 'package:frametrim/appviews/myserviceView.dart';

import 'attendanceQueryPage.dart';

class LaborServicePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => LaborServiceState();
}

class LaborServiceState extends State<LaborServicePage> {
  /*轮播图数据源*/
  List<Image> images = [
    Image.asset(
      'image/banner.png',
      fit: BoxFit.fill,
    ),
    Image.asset(
      'image/banner.png',
      fit: BoxFit.fill,
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion(
        value: SystemUiOverlayStyle.dark,
        child: Stack(
          children: <Widget>[
            /*背景*/
            Image.asset('image/background2.png',
                fit: BoxFit.cover, width: Screen.width, height: Screen.height),
            ListView(
              children: <Widget>[
                buildSwiper(),
                buildMyBackLog(),
                buildMyService(),
              ],
            ),
          ],
        ));
  }

  /*轮播图*/
  Widget buildSwiper() {
    var width = Screen.width - 20;
    return Container(
      margin: EdgeInsets.fromLTRB(10, 20, 10, 0),
      height: width / 18 * 10,
      child: Swiper(
        scrollDirection: Axis.horizontal,
        // 方向 Axis.horizontal
        itemBuilder: (context, index) {
          return images[index];
        },
        //不要用这个兴致，会报错
        // indicatorLayout: PageIndicatorLayout.COLOR,
        //条目个数
        itemCount: images.length,
        //自动翻页
        autoplay: true,
        //动画时间
        duration: 800,
        // 视窗比例
        // viewportFraction: 0.8,
        itemWidth: width-10,
        //页面切换间隔，默认3000ms
        autoplayDelay: 5000,
        //分页指示
        pagination:buildSwiperPagintion(),
        //点击事件
        onTap: (index) {
          print('点击的第${index}个');
        },
      ),
    );
  }

//指示器
  buildSwiperPagintion() {
    return SwiperPagination(
      //指示器显示的位置
      alignment: Alignment.bottomCenter, // 位置 Alignment.bottomCenter 底部中间
      // 距离调整
      margin: const EdgeInsets.fromLTRB(0, 0, 0, 5),
      // 指示器构建
      builder: DotSwiperPaginationBuilder(
          // 点之间的间隔
          space: 3,
          // // 没选中时的大小
          size: 8,
          // // 选中时的大小
          activeSize: 8,
          // 没选中时的颜色
          color: Colors.white.withOpacity(0.5),
          //选中时的颜色
          activeColor: Colors.white),
    );
  }

  /*我的待办*/
  Widget buildMyBackLog() {
    return Container(
      margin: EdgeInsets.all(10),
      padding: EdgeInsets.all(12),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(5), color: Colors.white),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            '我的待办',
            style: TextStyle(fontSize: 18, color: Colors.black),
          ),
          SizedBox(
            height: 15,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              BlockLobView('image/index_icon01.png', '工资确认', 3, SalarySure),
            ],
          ),
        ],
      ),
    );
  }

  /*我的服务*/
  Widget buildMyService(){
    return Container(
      margin: EdgeInsets.fromLTRB(10, 0, 10, 10),
      padding: EdgeInsets.all(12),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(5), color: Colors.white),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            '我的服务',
            style: TextStyle(fontSize: 18, color: Colors.black),
          ),
          SizedBox(
            height: 5,
          ),
          Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              ServiceView(SQColor.color_FDECE6,'image/index_icon03.png','考勤查询',(){}),
              ServiceView(SQColor.color_D8EBFD,'image/index_icon04.png','工资查询',(){
                AppNavigator.push(context, SalaryQueryPage());
              }),
              ServiceView(SQColor.color_D8EBFD,'image/icon_query.png','考勤查询',(){
                AppNavigator.push(context, AttendanceQueryPage());
              }),
              ServiceView(SQColor.color_CFFFEA,'image/icon_kqcx.png','项目考勤管理',(){
                AppNavigator.push(context, ProjectAttendanceManagementPage());
              }),
              ServiceView(SQColor.color_FFE9E9,'image/index_icon05.png','问题反馈',(){}),
            ],
          ),
        ],
      ),
    );
  }

  /*工资确认*/
  void SalarySure() {
    // AppNavigator.pushToSalarySure(context);
    AppNavigator.pushWithName(context, SalarySurePage(), 'SalarySure');
  }


}
